﻿using Apps.BLL.Report;
using Apps.Common;
using Apps.Models;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Apps.Web.ReportFile
{
    public partial class InventoryReport : System.Web.UI.Page
    {
        public static string _time = DateTime.Now.ToString();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                setInventoryReport(_time);
            }
        }

        public void setInventoryReport(string time)
        {
            var whereLambda = PredicateBuilder.True<CY_INVENTORY>();
            //whereLambda = whereLambda.And<CY_INVENTORY>(m => 1 == 1);
            if (string.IsNullOrEmpty(time))
                time = DateTime.Now.ToString();
            whereLambda = whereLambda.And<CY_INVENTORY>(m => m.INSERT_TIME == Convert.ToDateTime(time));
            var list = ReportBLL<CY_INVENTORY>.GetReportDataList(whereLambda);


            string strReportName = "CYInventoryReport";
            this._ReportViewer.LocalReport.ReportPath = string.Format(@"{0}\CYReport\" + strReportName + ".rdlc", Server.MapPath("."));
            this._ReportViewer.LocalReport.EnableExternalImages = true;
            this._ReportViewer.LocalReport.DataSources.Clear();
            ReportDataSource rds1 = new ReportDataSource("DataSet_Detail", list);
            this._ReportViewer.LocalReport.DataSources.Add(rds1);

        }
    }
}